package com.jz.warehouseareaclass.mapper;

import com.jz.legalpersonclass.model.LegalPersonVo;
import com.jz.planclass.model.PlanClassVo;
import com.jz.subclass.model.SubClassVo;
import com.jz.warehouseareaclass.model.WareReservoir;
import com.jz.warehouseareaclass.model.WarehouseareaSelectVo;
import com.jz.warehouseareaclass.model.WarehouseareaVo;
import org.apache.ibatis.annotations.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * Created by WISE on 2021/12/26.
 */
@Mapper
public interface WarehouseareaMapper {


    List<WarehouseareaVo> queryData(WarehouseareaSelectVo warehouseareaSelectVo);

    int queryCount(WarehouseareaSelectVo warehouseareaSelectVo);

    @Select("select * from warehousearea where code = #{code}")
    WarehouseareaVo queryByCode(String code);

    @Select("select * from warehousearea where name = #{name}")
    WarehouseareaVo queryByName(String name);

    @Insert("insert into warehousearea(wareHouseCode,name,code,status,remark,warehouseManagement,wmsIntegrate,vipStorageSection,createTime,createName)" +
            "values(#{wareHouseCode},#{name},#{code},#{status},#{remark},#{warehouseManagement},#{wmsIntegrate},#{vipStorageSection},#{createTime},#{createName})")
    void add(WarehouseareaVo classVo);

    @Select("select * from warehousearea where id = #{id}")
    List<WarehouseareaVo> queryById(Integer id);

    @Select("select code subCode from warehousearea where subName = #{subName}")
    WarehouseareaVo queryBySubName(@NotBlank(message = "备件小类名称不能为空") String subName);

    @Select("select code planCode from warehousearea where planName = #{planName}")
    WarehouseareaVo queryByPlanName(@NotBlank(message = "备件小类名称不能为空") String planName);

    @Select("select *  from legalpersonclass where legalPersonName = #{legalPersonName}")
    LegalPersonVo queryByLegalName(@NotBlank(message = "法人名称不能为空") String legalPersonName);

    @Select("select legalPersonCode legalCode,legalPersonName legalName from legalpersonclass where userId = #{userId}")
    List<WarehouseareaVo> queryByUserId(Integer userId);

    @Select("select * from subclass ")
    List<SubClassVo> queryAll();

    @Select("select * from planclass ")
    List<PlanClassVo> queryAll2();

    @Update("update warehousearea set name = #{name},updateTime = #{updateTime},updateName = #{updateName},remark = #{remark},code = #{code},status = #{status},warehouseManagement = #{warehouseManagement},wmsIntegrate = #{wmsIntegrate},vipStorageSection = #{vipStorageSection} where id = #{id}")
    int update(WarehouseareaVo classVo);

    @Update("update reservoirattributes set status = #{status},updateTime = #{updateTime},updateName = #{updateName} where id = #{id}")
    void updateStatus(WarehouseareaVo classVo);

    @Delete("delete from partlegal where partCode = #{code}")
    void delete(String code);

    void add1(WarehouseareaVo classVo);

    @Select("select * from warereservoir where wareHouseCode =#{code}")
    List<WareReservoir> selectFist(WarehouseareaVo classVo);

    @Delete("delete from warereservoir where wareHouseCode =#{code}")
    void deleteFirst(WarehouseareaVo classVo);
//@Select("select * from warehousearea ")
//    List<WarehouseareaVo> queryStorageSectionById(@Valid Integer id);
}
